<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich">

<h:head>
	<title>Registro de abastecimento</title>
</h:head>

<ui:composition template="/template/template.xhtml">
	<ui:define name="conteudo">
		<h:outputText value="Registro de Abastecimento"></h:outputText>
		<br />
		<br />
		<h:form>
			<a4j:outputPanel id="painelPrincipal">
				<div>
					<h:outputLabel value="Tipo de Cliente" />
					<h:selectOneRadio value="#{abastecimentoController.tipoCliente}"
						required="true" >
						<f:selectItem itemValue="1" itemLabel="Pessoa Física" />
						<f:selectItem itemValue="2" itemLabel="Pessoa Jurídica" />
						<f:selectItem itemValue="3" itemLabel="Dependente" />
					</h:selectOneRadio>
				</div>
				<div>
					<h:outputLabel value="Posto" />
				    
				    <h:selectOneMenu value="#{abastecimentoController.historico.posto.cnpj}" >    
					       <f:selectItems value="#{abastecimentoController.postos}" />    
					</h:selectOneMenu> 
				</div>
				
				<div>
					<h:outputLabel value="CPF/CNPJ/CNH" />
					<h:inputText value="#{abastecimentoController.historico.numeroDocumento}"
						required="true" />
				</div>
	
				<div>
					<h:outputLabel value="Valor" />
					<h:inputText value="#{abastecimentoController.historico.valor}"
						required="true" >
						 <f:convertNumber maxFractionDigits="2"/>
					</h:inputText>
				</div>
	
				
				<div>
					<h:commandButton value="Registrar" action="#{abastecimentoController.registar}" />
				</div>
	
				<div>
					<fieldset>
						<legend>
							<h:outputLabel value="Historico de Abastecimento" />
						</legend>
	
						<rich:dataTable value="#{abastecimentoController.lista}" var="historico"
							id="table" rows="20" rowClasses="odd-row, even-row" styleClass="stable">
							<rich:column>
								<f:facet name="header">
									<h:outputText value="Posto" />
								</f:facet>
								<h:outputText value="#{historico.posto.nomeFantasia}" />
							</rich:column>
							<rich:column>
								<f:facet name="header">
									<h:outputText value="CPF/CNPJ/CNH" />
								</f:facet>
								<h:outputText value="#{historico.numeroDocumento}" />
							</rich:column>
							<rich:column>
								<f:facet name="header">
									<h:outputText value="Valor" />
								</f:facet>
								<h:outputText value="#{historico.valor}" />
							</rich:column>
						</rich:dataTable>
			
					<rich:jQuery selector=".stable tr:odd" query="addClass('odd-row')" />
					<rich:jQuery selector=".stable tr:even" query="addClass('even-row')" />
					<rich:jQuery selector=".stable tr" event="mouseover" query="jQuery(this).addClass('active-row')" />
					<rich:jQuery selector=".stable tr" event="mouseout" query="jQuery(this).removeClass('active-row')" />
					</fieldset>
	
				</div>
			</a4j:outputPanel>
		</h:form>
	</ui:define>
</ui:composition>
</html>